package framework.formfields;

import java.lang.reflect.Field;

import framework.FormField;

public class FormRadioField extends FormField{

	String[] opcoes;
	
	public FormRadioField(Field field, String[] opcoes) throws SecurityException,
			NoSuchFieldException {
		super(field);
		this.opcoes = opcoes;
	}

	public String gerarLinha(Object objeto) throws Exception, Throwable {
		String linhaGerada = "<tr> <td>" + getLabel() + "</td> <td>";
		for (int i = 0; i < opcoes.length; i++)
		{
			linhaGerada += "<INPUT TYPE=\"RADIO\" value=\"" + opcoes[i] + "\" name=\""+ label +"\"";
			if (getField().get(objeto).equals(opcoes[i]))
			{
				linhaGerada += " checked=\"checked\" ";
			}
			linhaGerada += ">" + opcoes[i];
		}
		linhaGerada += "</td> </tr>\n";
		return linhaGerada;
	}

}
